package com.cddx.logistics.service.impl;

import com.cddx.logistics.domain.dto.VehicleQueryDTO;
import com.cddx.logistics.domain.pojo.Vehicle;
import com.cddx.logistics.domain.vo.VehicleVO;
import com.cddx.logistics.mapper.VehicleMapper;
import com.cddx.logistics.service.VehicleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VehicleServiceImpl implements VehicleService {
    @Resource
    private VehicleMapper vehicleMapper;

    @Override
    public PageInfo<VehicleVO> queryPage(VehicleQueryDTO queryDTO) {
        PageHelper.startPage(queryDTO.getPage(), queryDTO.getLimit());
        List<VehicleVO> list = vehicleMapper.queryPage(queryDTO);
        return new PageInfo<>(list);
    }

    @Override
    public boolean add(Vehicle vehicle) {
        return vehicleMapper.add(vehicle) > 0;
    }

    @Override
    public boolean update(Vehicle vehicle) {
        return vehicleMapper.update(vehicle) > 0;
    }

    @Override
    public boolean delete(Integer id) {
        return vehicleMapper.delete(id) > 0;
    }

    @Override
    public boolean batchDelete(List<Integer> ids) {
        return vehicleMapper.batchDelete(ids) > 0;
    }
}
